#@layout()

#define main()
<div class="jfa-header-box" id="jfa-header-box">
	<div class="jfa-crumbs" id="jfa-crumbs">
		线上电泳框信息
	</div>
	#include("/_view/common/_header_right.html")
</div>
<div class="jfa-content-box" id="jfa-content-box">
	<div class="jfa-content" id="jfa-content">
	    <div class="margin-top-30">
			<form class="form-horizontal actionPanel" action="#" method="get">
		        <div class="row">
		             <div class="form-group col-lg-4">
		                 <label class="col-sm-3 control-label">挂框</label>
		                 <div class="col-sm-9">
		                     <input type="text" id="form-rackNo" class="form-control" name="rackNo" value="">
		                 </div>
		             </div>
		             <div class="form-group col-lg-4">
		                 <label class="col-sm-3 control-label">追溯号</label>
		                 <div class="col-sm-9">
		                     <input type="text" id="form-traceCode" class="form-control" name="traceNo" value="">
		                 </div>
		             </div>
		             <div class="form-group col-lg-4">
                         <div class="col-sm-12">
                             <button type="button" class="btn btn-primary" onclick="searchRack()">查询</button>
                             <button type="reset" class="btn btn-default">重置</button>
                         </div>
                     </div>
		         </div>
		    </form>
		</div>
		

		<div id="toolbar" class="btn-group">
	        <a class="btn btn-primary btn-sm margin-right-10" href="#" onclick="lineForward()">
				<i class="fa fa-arrow-up"></i>
				全线前进
			</a>
			<a class="btn btn-primary btn-sm " href="#" onclick="lineBackward()">
				<i class="fa fa-arrow-down"></i>
				全线倒退
			</a>
			
	    </div>
		<table id="lineRack">
			
		</table>
	</div>
</div>
<script type="text/javascript">
 	var datagridHeight=$("#jfa-content").height()-80;
 	$('#lineRack').bootstrapTable({
        url: '#(ctx)/admin/lineRack/list',         
        method: 'get',
        toolbar: '#toolbar',
        striped: true,
        cache: false,
        pagination: true,
        sortable: false,                    
        sortOrder: "asc",  
        queryParams: function (params) {
	            var data = { 
	                    pageSize: params.limit,
	                    offset: params.offset,
	                    'rackNo': $("#form-rackNo").val(),
	                    'traceCode': $("#form-traceCode").val(),
	            };
	            return data;
        },
        sidePagination: "server",
        pageNumber:1,
        toolbarAlign:"right",
        pageSize:210,         
        pageList: [210, 420,100],
        search: false,
        strictSearch: true,
        showColumns: false,
        showRefresh: false,             
        minimumCountColumns: 2,
        clickToSelect: true,               
       	height: datagridHeight,
        uniqueId: "id",
        showToggle:false,
        cardView: false,
        detailView: false,
        columns: [
            {
                field: 'hanger_no',  title: '挂具编号'
            }, {
                field: 'frame_no',  title: '电泳框编号'
            }, {
                field: 'barcode',  title: '条码'
            }, {
                field: 'trace_no',  title: '追溯编号'
            }, {
                field: 'material_count',  title: '物料数量'
            }, {
            	field: 'location_name',  title: '位置'
            },{
                title: '操作',formatter:operaterFormatter
            }
        ]
    });


function operaterFormatter(value, row, index){
	return "<a href='#(ctx)/admin/lineRack/edit?id="+row.id+"'>"+
	"<i class='fa fa-pencil' title='修改'></i>"+
	" </a> &nbsp"+
	"<a data-pjax href=\"#(ctx)/admin/lineRack/print?id="+row.id+"\">"+
	"	<i class='fa fa-print' title='打印'></i>"+
	"</a> &nbsp"+
	"<a href='#' onclick='rackForward(\""+row.id+"\")'>"+
	"	<i class='fa fa-arrow-up' title='前进'></i>"+
	"</a> &nbsp"+
	"<a href='#' onclick='rackBackward(\""+row.id+"\")'>"+
	"	<i class='fa fa-arrow-down' title='后退'></i>"+
	"</a> &nbsp"+
	"<a  href='#' onclick='deleteRack(\""+row.id+"\")'>"+
	"	<i class='fa fa-trash' title='删除'></i>"+
	"</a>"
}



function searchRack(){
	$('#lineRack').bootstrapTable("refresh",{silent: true});
    layer.msg('操作成功');
}

function deleteRack(id){
	layer.confirm("确认删除该记录？", {
		icon: 0
		, title:'' 
		, shade: 0.4
		, offset: "139px"
	}, function(index) { 
		$.ajax({
			url:"#(ctx)/admin/lineRack/delete",
			data:{"id":id},
			dataType:"json",
			success:function(ret){
				$('#lineRack').bootstrapTable("refresh",{silent: true});
			    layer.msg(ret.msg);
			    layer.close(index);   
			},
			error:function(){
				layer.close(index);   
			}
		});                           
		                       
	});
}

function rackForward(id){
	layer.confirm("确认让该电泳框前进一次？", {
		icon: 0
		, title:'' 
		, shade: 0.4
		, offset: "139px"
	}, function(index) { 
		$.ajax({
			url:"#(ctx)/admin/lineRack/rackForward",
			data:{"id":id},
			dataType:"json",
			success:function(ret){
				$('#lineRack').bootstrapTable("refresh",{silent: true});
			    layer.msg(ret.msg);
			    layer.close(index);   
			},
			error:function(){
				layer.close(index);   
			}
		});                           
		                       
	});
}


function rackBackward(id){
	layer.confirm("确认让该电泳框后退一次？", {
		icon: 0
		, title:'' 
		, shade: 0.4
		, offset: "139px"
	}, function(index) { 
		$.ajax({
			url:"#(ctx)/admin/lineRack/rackBackward",
			data:{"id":id},
			dataType:"json",
			success:function(ret){
				$('#lineRack').bootstrapTable("refresh",{silent: true});
			    layer.msg(ret.msg);
			    layer.close(index);   
			},
			error:function(){
				layer.close(index);   
			}
		});                           
		                       
	});
}

function lineForward(){
	layer.confirm("确认让产线整体前进一次？", {
		icon: 0
		, title:'' 
		, shade: 0.4
		, offset: "139px"
	}, function(index) { 
		$.ajax({
			url:"#(ctx)/admin/lineRack/lineForward",
			dataType:"json",
			success:function(ret){
				$('#lineRack').bootstrapTable("refresh",{silent: true});
			    layer.msg(ret.msg);
			    layer.close(index);   
			},
			error:function(){
				layer.close(index);   
			}
		});                           
		                       
	});
}



function lineBackward(){
	layer.confirm("确认让产线整体后退一次？", {
		icon: 0
		, title:'' 
		, shade: 0.4
		, offset: "139px"
	}, function(index) { 
		$.ajax({
			url:"#(ctx)/admin/lineRack/lineBackward",
			dataType:"json",
			success:function(ret){
				$('#lineRack').bootstrapTable("refresh",{silent: true});
				layer.msg(ret.msg);
			    layer.close(index);   
			},
			error:function(){
				layer.close(index);   
			}
		});                           
		                       
	});
}
</script>
#end
